@echo off
rem Prerequisites for running this script:
rem 1.  Python 2.7 is installed
rem 2.  Mustache is available from the command line
rem
rem This system uses the Node.js version of Mustache
rem
rem To install, run:
rem npm install mustache -g
rem

SET OUTPUT_FILE=TOBswagger.yaml

rem make a backup of the current output file.

copy %OUTPUT_FILE% %OUTPUT_FILE%.bck

SET PYTHONCMD=C:\Python27\python.exe

rem convert csv files to json

rem IMPORTANT - do not add the yes parameter here, as it will result in empty yaml output
%PYTHONCMD% TestData/csv2json.py in\model.csv
%PYTHONCMD% TestData/csv2json.py in\api.csv

rem generate sections of swagger files

echo.
echo Generating Model YAML
echo.

call mustache "model/model_Defs.json" "templates/model.mustache" >model.yaml

echo.
echo Generating API YAML
echo.

call mustache "api/api_Defs.json" "templates/api.mustache" >api.yaml

echo.
echo Merging YAML
echo.


rem file definitions:
rem header.yaml - edit this to change the upper portion of the output
rem api.yaml - generated by the above script
rem postapi.yaml - edit this to change the static text included after the generated
rem model.yaml - generated by the above script
rem footer.yaml - edit this to change the footer.
copy /b header.yaml+api.yaml+postapi.yaml+model.yaml+footer.yaml %OUTPUT_FILE%
